package com.andromeda.tutorial;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class iTem {

	private Bitmap img;
	private Bitmap imgShape;
	private Bitmap imgExpo;
	private Bitmap imgSelected;
	private int coordX;
	private int coordY;
	private int expoCoordX;
	private int expoCoordY;
	private int shapeCoordX;
	private int shapeCoordY;
	private int center_x;
	private int center_y;
	private int i;
	
	public iTem(Context context, int drawable,int drawable2,int drawable3, int coordX, int coordY,int i) {
		
		super();
		
		BitmapFactory.Options opts = new BitmapFactory.Options();
		opts.inJustDecodeBounds = true;
		
		img = BitmapFactory.decodeResource(context.getResources(), drawable);
		this.imgShape=BitmapFactory.decodeResource(context.getResources(), drawable2);
		this.imgSelected=BitmapFactory.decodeResource(context.getResources(), drawable3);
		this.imgExpo=img;
		
		this.center_x=coordX;
		this.center_y=coordY;
		this.coordX = coordX-img.getWidth()/2;
		this.coordY = coordY-img.getHeight()/2;
		this.expoCoordX=this.coordX;
		this.expoCoordY=this.coordY;
		this.shapeCoordX=coordX-imgShape.getWidth()/2;
		this.shapeCoordY=coordY-imgShape.getHeight()/2;
		
		this.i=i;
	}
	
	
	public void shake(){
		if(i==1){
			coordX=shapeCoordX-2;
			coordY=shapeCoordY+3;
			i++;
		}
		else if(i==2){
			coordY=shapeCoordY-3;
			i++;
		}
		else if(i==3){
			coordX=shapeCoordX-2;
			i++;
		}
		else if(i==4){
			coordX=shapeCoordX+3;
			coordY=shapeCoordY+2;
			i++;
		}
		else if(i==5){
			coordX=shapeCoordX-3;
			coordY=shapeCoordY-2;
			i++;
		}
		else if(i==6){
			coordX=shapeCoordX+3;
			i++;
		}
		else if(i==7){
			coordY=shapeCoordY+2;
			i++;
		}
		else if(i==8){
			coordX=shapeCoordX+2;
			coordY=shapeCoordY-3;
			i=1;
		}
	}
	

	public void getConstantPlace() {
		this.coordX=expoCoordX;
		this.coordY=expoCoordY;
	}
	
	public void turnToShape(){
	    this.img=imgShape;	
	    this.coordX=shapeCoordX;
	    this.coordY=shapeCoordY;
	}
	
	public void turnToShape(int i){
	    this.img=imgShape;	
	}
	
	public void turnToExpo(){
		this.img=imgExpo;
		this.coordX=expoCoordX;
		this.coordY=expoCoordY;
	}
	
	public void turnToSelected(){
		this.img=imgSelected;
	}

	public Bitmap getImg() {
		return img;
	}
	
	public Bitmap getImgShape() {
		return imgShape;
	}


	public int getCoordX() {
		return coordX;
	}

	public int getCoordY() {
		return coordY;
	}

	public void setCoordX(int coordX) {
		this.coordX = coordX;
	}

	public void setCoordY(int coordY) {
		this.coordY = coordY;
	}


	public int getCenter_x() {
		return center_x;
	}


	public int getCenter_y() {
		return center_y;
	}
	 
}

